<template>
	<view>
		<!-- 头部 -->
		<!-- #ifndef MP-WEIXIN -->
		<public-header :title="title" :share="false"></public-header>
		<view class="hei_100"></view>
		 <!-- #endif -->
		<!-- end -->
		<view class="padd_32">
			<mescroll-body top="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
				<comment-list :list="table"></comment-list>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
import PublicHeader from '@/components/PublicHeader.vue';
import CommentList from '@/components/list/list-comment.vue';
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue';
	export default {
	mixins: [MescrollMixin],
		components: {
			MescrollBody,
			PublicHeader,
			CommentList
		},
		data() {
			return {
				title: '评价',
				table: [],
				id: '',
				type: '',
				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
					auto: true,
					textNoMore: '没有更多数据',
					page: {
					  num : 0,
					  size : 10,
					  time : null
					}
				}
			}
		},
		onLoad(option){
			this.id = option.sid
			this.type = option.type
			console.log(option)
		},
		methods: {
			downCallback(page) {
				console.log('下拉')
				var _this = this
				_this.table = []
				_this.mescroll.resetUpScroll()
			},
			//上拉加载的回调
			upCallback(page) {
				console.log('上拉')
				var _this = this
				if (this.type == '商家') {
					console.log('商家')
					_this.$http
						.post('/ent/manage/show/appraise/',{
							page:page.num,
							size:page.size,
							shopId:_this.id
						})
						.then(function(response) {
							
							_this.mescroll.endBySize(response.data.list.length, response.data.total)
							//设置列表数据
							_this.table=_this.table.concat(response.data.list);
							
						})
						.catch(function(error) {
							console.log(error);
							_this.mescroll.endErr();
						});
				}
				if (this.type == '员工') {
					console.log('员工')
					_this.$http
						.get('/emp/info/appraises/',{
							page:page.num,
							size:page.size,
							employeeId:_this.id
						})
						.then(function(response) {
							
							_this.mescroll.endBySize(response.data.list.length, response.data.total)
							//设置列表数据
							_this.table=_this.table.concat(response.data.list);
							
						})
						.catch(function(error) {
							console.log(error);
							_this.mescroll.endErr();
						});
				}
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
